package com.bw.home.repo

import androidx.compose.runtime.mutableStateListOf
import com.bw.home.ApiService
import com.bw.home.entity.CollectEntity
import com.bw.home.entity.SimpleTypeEntity
import com.bw.home.entity.SimpleVideoEntity
import com.bw.lib_miv.BaseRepo
import com.bw.lib_net.BaseRes
import com.bw.lib_net.RetrofitManager
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class HomeRepo @Inject constructor() : BaseRepo() {
    private val apiService by lazy { RetrofitManager.getRetrofit().create(ApiService::class.java) }

    //获取类型
    fun getSimpleType() = apiService.getSimpleType()

    //获取数据
    fun getSimpleVideo(id: String, page: Int, size: Int) = apiService.getSimpleVideo(id, page, size)

    //猜您喜欢
    fun getRecommendSimpleVideo(page: Int, size: Int) =
        apiService.getRecommendSimpleVideo(page, size)

    //评论
    fun getComment(type: Int, id: String) = apiService.getComment(type, id)

    //收藏
    fun getCollect(entity: CollectEntity) = apiService.getCollect(entity)

    //取消收藏
    fun unCollect(entity: CollectEntity) = apiService.unCollect(entity)

    //登录
    fun login(username: String, password: String) = apiService.login(username, password)

    //注册
    fun register(username: String, password: String) = apiService.register(username, password)

    //修改密码
    fun updatePassword(userId:Int,newPassword:String) = apiService.updatePassword(userId, newPassword)


    var tempItem: SimpleVideoEntity? = null

    fun getVideoItem() = tempItem

    fun setVideoItem(item: SimpleVideoEntity) {
        tempItem = item
    }

}